package com.rentong.basic;

import org.apache.commons.lang3.StringUtils;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.GetMapping;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

/**
 * @author ZXY
 * @ClassName: PageController
 * @Description:
 * @date 2017/10/12 20:15
 */

@Controller
public class PageController {

    //通用请求地址，不带参数
    @GetMapping("/page/**")
    public String page(HttpServletRequest request, HttpServletResponse response) {
        String uri = request.getServletPath();
        String url = uri.replaceFirst("/page/", "").replaceFirst("\\.html", "");

        if (StringUtils.isBlank(url)) {
            url = "404";
        }
        return url;
    }

//    @GetMapping("/**/*.html")
//    public String html(HttpServletRequest request, HttpServletResponse response) {
//        String uri = request.getServletPath();
//        String url = uri.replaceFirst("/", "").replaceFirst("\\.html", "");
//
//        if (StringUtils.isBlank(url)) {
//            url = "404";
//        }
//        return url;
//    }
}
